﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;

namespace QLQTPM_Nhom03
{
    public partial class HelpForm : Form
    {
        List<Image> imgList = new List<Image>();
        private int _currentImage = 1;

        public HelpForm()
        {
            InitializeComponent();
        }

        private void HelpForm_Load(object sender, EventArgs e)
        {
            //Khởi tạo image list
            Image i1 = Properties.Resources.Trang1;
            Image i2 = Properties.Resources.Trang2;
            Image i3 = Properties.Resources.Trang3;
            Image i4 = Properties.Resources.Trang4;
            Image i5 = Properties.Resources.Trang5;

            imgList.Add(i1);
            imgList.Add(i2);
            imgList.Add(i3);
            imgList.Add(i4);
            imgList.Add(i5);

            _currentImage = 0;            
            pb_1.Image = imgList[_currentImage];

            //Khởi tạo Checkbox Startup
            RegistryKey regMySoft = RegistryUtil.Create();
            if (regMySoft != null)
            {
                RegistryKey tempKey = regMySoft.OpenSubKey("HelpStartup");

                if (tempKey.GetValue("Startup").ToString() == "1")
                    cb_Startup.Checked = true;
                else
                    cb_Startup.Checked = false;
            }            
        }

        private void pb_1_Click(object sender, EventArgs e)
        {

        }

        private void btn_Next_Click(object sender, EventArgs e)
        {
            if (_currentImage < imgList.Count - 1)
                _currentImage++;
            pb_1.Image = imgList[_currentImage];
        }

        private void btn_Close_Click(object sender, EventArgs e)
        {
            this.Owner.Enabled = true;
            this.Owner.Focus();
            this.Close();
        }

        private void btn_Back_Click(object sender, EventArgs e)
        {
            if (_currentImage > 0)
                _currentImage--;
            pb_1.Image = imgList[_currentImage];
        }

        private void cb_Startup_CheckedChanged(object sender, EventArgs e)
        {
            RegistryKey regMySoft = RegistryUtil.Create();
            if (regMySoft != null)
            {
                RegistryKey tempKey = regMySoft.OpenSubKey("HelpStartup", true);
                if (cb_Startup.Checked == true)
                    tempKey.SetValue("Startup", "1");
                else
                    tempKey.SetValue("Startup", "0");
            }
        }
    }
}
